package logic

import (
	"context"
	"github.com/zeromicro/go-zero/core/logx"
	"group/internal/svc"
	"group/pb/group"
)

type HandleApplyLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewHandleApplyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HandleApplyLogic {
	return &HandleApplyLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// HandleApply 处理群聊申请
func (l *HandleApplyLogic) HandleApply(in *group.ApplyInfo) (*group.Empty, error) {
	//err := l.svcCtx.GroupApplyModel.Update(l.ctx, &models.GroupApply{
	//	Id:            in.Id,
	//	Status:        in.Status,
	//	HandlerUserId: in.HandlerUserId,
	//	HandleTime: sql.NullTime{
	//		Valid: true,
	//		Time:  time.Unix(in.HandlerTime, 0),
	//	},
	//})

	err := l.svcCtx.ChatGroupAggregationModel.HandleGroupApply(l.ctx, in.Id, in.HandlerUserId, in.GroupId, in.Status)
	if err != nil {
		return nil, err
	}
	return &group.Empty{}, nil
}
